import 'package:flutter/material.dart';

enum LoadMoreStatus {LOADING, END, ERROR,FINISH }

//加载布局基类
abstract class BaseLoadMoreView extends StatelessWidget {
  LoadMoreStatus loadMoreStatus;

  @protected
  Widget buildLoading(BuildContext context);

  @protected
  Widget buildEnd(BuildContext context);

  @protected
  Widget buildError(BuildContext context);

  Widget _buildBody(BuildContext context) {
    if (loadMoreStatus == LoadMoreStatus.END) {
      return buildEnd(context);
    } else if (loadMoreStatus == LoadMoreStatus.ERROR) {
      return buildError(context);
    }
    return buildLoading(context);
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: EdgeInsets.only(top: 16, bottom: 16),
        child: Center(
          child: _buildBody(context),
          heightFactor: 1,
        ),
    );
  }
}
